-- Copyright (c) Huawei Technologies Co., Ltd. 2025. All rights reserved.
--
-- this file licensed under the Mulan PSL v2.
-- You can use this software according to the terms and conditions of the Mulan PSL v2.
-- You may obtain a copy of Mulan PSL v2 at: http://license.coscl.org.cn/MulanPSL2
--
-- THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
-- PURPOSE.
-- See the Mulan PSL v2 for more details.
--
-- Author: auto generate
-- Create: 2025-10-30
-- Description: DO NOT EDIT; Code generated by "message.lua.mako"
local validate = require 'mc.validate'
local utils = require 'mc.utils'

local MSyncDestination = {}

---@class MSyncDestination.DestinationFilter
---@field DestinationFilter integer
local TDestinationFilter = {}
TDestinationFilter.__index = TDestinationFilter
TDestinationFilter.group = {}

local function TDestinationFilter_from_obj(obj)
    return setmetatable(obj, TDestinationFilter)
end

function TDestinationFilter.new(DestinationFilter)
    return TDestinationFilter_from_obj({DestinationFilter = DestinationFilter or 0})
end
---@param obj MSyncDestination.DestinationFilter
function TDestinationFilter:init_from_obj(obj)
    self.DestinationFilter = obj.DestinationFilter or 0
end

function TDestinationFilter:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TDestinationFilter.group)
end

TDestinationFilter.from_obj = TDestinationFilter_from_obj

TDestinationFilter.proto_property = {'DestinationFilter'}

TDestinationFilter.default = {0}

TDestinationFilter.struct = {{name = 'DestinationFilter', is_array = false, struct = nil}}

function TDestinationFilter:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'DestinationFilter', self.DestinationFilter, 'uint8', false, errs, need_convert)

    TDestinationFilter:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TDestinationFilter.proto_property, errs, need_convert)
    return self
end

function TDestinationFilter:unpack(_)
    return self.DestinationFilter
end

MSyncDestination.DestinationFilter = TDestinationFilter

---@class MSyncDestination.Port
---@field Port integer
local TPort = {}
TPort.__index = TPort
TPort.group = {}

local function TPort_from_obj(obj)
    return setmetatable(obj, TPort)
end

function TPort.new(Port)
    return TPort_from_obj({Port = Port or 51000})
end
---@param obj MSyncDestination.Port
function TPort:init_from_obj(obj)
    self.Port = obj.Port or 51000
end

function TPort:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TPort.group)
end

TPort.from_obj = TPort_from_obj

TPort.proto_property = {'Port'}

TPort.default = {0}

TPort.struct = {{name = 'Port', is_array = false, struct = nil}}

function TPort:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Port', self.Port, 'uint16', false, errs, need_convert)

    TPort:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TPort.proto_property, errs, need_convert)
    return self
end

function TPort:unpack(_)
    return self.Port
end

MSyncDestination.Port = TPort

---@class MSyncDestination.Address
---@field Address string
local TAddress = {}
TAddress.__index = TAddress
TAddress.group = {}

local function TAddress_from_obj(obj)
    return setmetatable(obj, TAddress)
end

function TAddress.new(Address)
    return TAddress_from_obj({Address = Address or [=[]=]})
end
---@param obj MSyncDestination.Address
function TAddress:init_from_obj(obj)
    self.Address = obj.Address or [=[]=]
end

function TAddress:remove_error_props(errs, obj)
    utils.remove_obj_error_property(obj, errs, TAddress.group)
end

TAddress.from_obj = TAddress_from_obj

TAddress.proto_property = {'Address'}

TAddress.default = {''}

TAddress.struct = {{name = 'Address', is_array = false, struct = nil}}

function TAddress:validate(prefix, errs, need_convert)
    prefix = prefix or ''

    validate.Optional(prefix .. 'Address', self.Address, 'string', false, errs, need_convert)

    TAddress:remove_error_props(errs, self)
    validate.CheckUnknowProperty(self, TAddress.proto_property, errs, need_convert)
    return self
end

function TAddress:unpack(_)
    return self.Address
end

MSyncDestination.Address = TAddress

return MSyncDestination
